package yuanzhui;

	import java.util.LinkedList;
	import java.util.ListIterator;
	import java.util.Scanner;

	public class Notepad {
		public void add(LinkedList<String> list) {
			System.out.println("请输入");
			System.out.println("输入一个单独的#号结束");
			Scanner reader = new Scanner(System.in);
			while (!reader.hasNext("#")) {
				String a = reader.next();
				list.add(a);
			}
			System.out.println(list);
		}

		public void change(LinkedList<String> list) {
			ListIterator<String> it = (ListIterator<String>) list.iterator();
			Scanner reader = new Scanner(System.in);
			System.out.println("请输入被替换的内容");
			String a = reader.next();
			System.out.println("请输入替换的新内容");
			String b = reader.next();
			while (it.hasNext()) {

				String c = it.next();
				if (c.contains(a)) {
					it.set(b);
				} else {
					System.out.println("没有找到被替换的内容");
				}
			}
			System.out.println(list);

		}

		public void del(LinkedList<String> list) {
			System.out.println("输入1的时候删除当前字符");
			System.out.println("输入其他字符的时候退出");
			Scanner reader = new Scanner(System.in);
			int a = reader.nextInt();
			while (a == 1) {
				if (list.size() != 0) {
					String b = list.getLast();
					if (!b.equals("")) {
						b = b.substring(0, b.length() - 1);
						list.removeLast();
						list.add(b);
					} else {
						list.removeLast();
					}
				} else {
					System.out.println("记事本为空");
				}
				System.out.println(list);
				a = reader.nextInt();
			}
		}

		public void seach(LinkedList<String> list) {
			System.out.println("请输入要查询的内容");
			Scanner reader = new Scanner(System.in);
			String a = reader.next();
			if (list.contains(a)) {
				System.out.println("找到了");
			} else {
				System.out.println("没有找到");
			}
		}

	}

